package easy; /**
 * 最小和且大于0
 */

import java.util.Arrays;

public class test14 {
    public static void main(String[] args) {
        test14 test14 = new test14();
        int[] nums = {-3, 2, -3, 4, 2, 4, -5};
        System.out.println(test14.minStartValue(nums));
    }

    public int minStartValue(int[] nums) {
        int a = 0;
        int[] ints = new int[nums.length];
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
            ints[i] = sum;
        }
        Arrays.sort(ints);
        System.out.println(Arrays.toString(ints));
        for (Integer i : ints) {
            if (i > 0) {
                return i;
            }
        }
        return -1;
    }
}
